// pages/customization/customization.js
// var myDate = new Date();
// var hm = myDate.getHours() + ":" + myDate.getMinutes()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    money: 0,
    array: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
    username: null,
    phonenumber: null,
    wechat: null,
    gotime: "07" + ":" + 30,
    goaddress: null,
    shangbantime: "09" + ":" + "00",
    shangbanaddress: null,
    ingohometime: 18 + ":" + "00",
    infangshi: null,
    // money: null,
    inreferrer:null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this
    var money = that.data.money
    var username = that.data.username
    var phonenumber = that.data.phonenumber
    var wechat = that.data.wechat
    var goaddress = that.data.goaddress
    var gotime = that.data.gotime
    var shangbantime = that.data.shangbantime
    var shangbanaddress = that.data.shangbanaddress
    var ingohometime = that.data.ingohometime
    var infangshi = that.data.infangshi
    var inreferrer = that.data.inreferrer
    wx.getStorage({
      key: 'inreferrer',
      success: function(res) {
        console.log(res.data)
        that.setData({
          inreferrer:res.data
        })
      },
    })
      wx.getStorage({
      key: 'money',
      success: function(res) {
        console.log(res.data)
        that.setData({
          money: res.data
        })
      },
    })
    wx.getStorage({
      key: 'username',
      success: function(res) {
        console.log(res.data)
        that.setData({
          username: res.data
        })
      },
    })
    wx.getStorage({
      key: 'phonenumber',
      success: function(res) {
        console.log(res.data)
        that.setData({
          phonenumber: res.data
        })
      },
    })
    wx.getStorage({
      key: 'wechat',
      success: function(res) {
        console.log(res.data)
        that.setData({
          wechat: res.data
        })
      },
    })
    wx.getStorage({
      key: 'gotime',
      success: function(res) {
        console.log(res.data)
        that.setData({
          gotime: res.data
        })
      },
    })
    wx.getStorage({
      key: 'goaddress',
      success: function(res) {
        console.log(res.data)
        that.setData({
          goaddress: res.data
        })
      },
    })
    wx.getStorage({
      key: 'shangbantime',
      success: function(res) {
        console.log(res.data)
        that.setData({
          shangbantime: res.data
        })
      },
    })
    wx.getStorage({
      key: 'ingohometime',
      success: function(res) {
        console.log(res.data)
        that.setData({
          ingohometime: res.data
        })
      },
    })
    wx.getStorage({
      key: 'infangshi',
      success: function(res) {
        console.log(res.data)
        that.setData({
          infangshi: res.data
        })
      },
    })
    wx.getStorage({
      key: 'shangbanaddress',
      success: function(res) {
        console.log(res.data)
        that.setData({
          shangbanaddress: res.data
        })
      },
    })
    wx.getStorage({
      key: 'infangshi',
      success: function(res) {
        console.log(res.data)
        that.setData({
          infangshi:res.data
        })
      },
    })
  },
  gotime: function(e) {
    console.log("姓名改变", e.detail.value)
    this.setData({
      gotime: e.detail.value
    })
  },
  shangbantime: function(e) {
    console.log("姓名改变", e.detail.value)
    this.setData({
      shangbantime: e.detail.value
    })
  },
  shangbanaddress: function(e) {
    console.log("姓名改变", e.detail.value)
    this.setData({
      shangbanaddress: e.detail.value
    })
  },
  goaddress: function(e) {
    console.log("姓名改变", e.detail.value)
    this.setData({
      goaddress: e.detail.value
    })
  },
  ingohometime: function(e) {
    console.log("姓名改变", e.detail.value)
    this.setData({
      ingohometime: e.detail.value
    })
  },
  infangshi: function(e) {
    console.log("姓名改变", e.detail.value)
    this.setData({
      infangshi: e.detail.value
    })
  },
  money: function(e) {
    console.log("姓名改变", e.detail.value)
    this.setData({
      money: e.detail.value
    })
  },
  wechat: function(e) {
    console.log("姓名改变", e.detail.value)
    this.setData({
      wechat: e.detail.value
    })
  },
  phonenumber: function(e) {
    console.log("姓名改变", e.detail.value)
    this.setData({
      phonenumber: e.detail.value
    })
  },
  username: function(e) {
    console.log("姓名改变", e.detail.value)
    this.setData({
      username: e.detail.value
    })
  },
  inreferrer:function(e){
console.log(e.detail.value)
    this.setData({ inreferrer:e.detail.value})
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },
  tijiao: function(e) {
    var money = this.data.money
    var username = this.data.username
    var phonenumber = this.data.phonenumber
    var wechat = this.data.wechat
    var goaddress = this.data.goaddress
    var gotime = this.data.gotime
    var shangbantime = this.data.shangbantime
    var shangbanaddress = this.data.shangbanaddress
    var ingohometime = this.data.ingohometime
    var infangshi = this.data.infangshi
    var inreferrer = this.data.inreferrer
    if (username == null) {
      wx.showToast({
        title: '请输入姓名',
        icon: 'none',
        image: '',
        duration: 1500,
        mask: true,
        success: function(res) {},
        fail: function(res) {},
        complete: function(res) {},
      })
    } else if (phonenumber == null) {
      wx.showToast({
        title: '请输入手机号',
        icon: 'none',
        image: '',
        duration: 1500,
        mask: true,
        success: function(res) {},
        fail: function(res) {},
        complete: function(res) {},
      })
    } else if (wechat == null) {
      wx.showToast({
        title: '请输入微信号',
        icon: 'none',
        image: '',
        duration: 1500,
        mask: true,
        success: function(res) {},
        fail: function(res) {},
        complete: function(res) {},
      })
    } else if (goaddress == null) {
      wx.showToast({
        title: '请输入出行地址',
        icon: 'none',
        image: '',
        duration: 1500,
        mask: true,
        success: function(res) {},
        fail: function(res) {},
        complete: function(res) {},
      })
    } else {
      wx.request({
        url: 'https://romforandroid.cn/qiandao.php',
        data: {
          inreferrer: inreferrer,
          username:username,
          money:money,
          phonenumber:phonenumber,
          wechat:wechat,
          gotime:gotime,
          goaddress:goaddress,
          shangbantime: shangbantime,
          shangbanaddress: shangbanaddress,
          ingohometime: ingohometime,
          infangshi: infangshi
        },
        success: function(de) {
          wx.showToast({
            title: '提交成功',
          })
          wx.clearStorage()
        },
        fail: function() {
          wx.showToast({
            title: '提交失败',
          })
          wx.setStorage({
            key: 'username',
            data: username,
          })
          wx.setStorage({
            key: 'money',
            data: money,
          })
          wx.setStorage({
            key: 'phonenumber',
            data: phonenumber,
          })
          wx.setStorage({
            key: 'wechat',
            data: wechat,
          })
          wx.setStorage({
            key: 'gotime',
            data: gotime,
          })
          wx.setStorage({
            key: 'goaddress',
            data: goaddress,
          })
          wx.setStorage({
            key: 'shangbantime',
            data: shangbantime,
          })
          wx.setStorage({
            key: 'shangbanaddress',
            data: shangbanaddress,
          })
          wx.setStorage({
            key: 'ingohometime',
            data: ingohometime,
          })
          wx.setStorage({
            key: 'infangshi',
            data: infangshi,
          })
          wx.setStorage({
            key: 'inreferrer',
            data: inreferrer,
          })
        }
      })
    }
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})